/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Gui;

import com.sun.corba.se.impl.protocol.giopmsgheaders.Message;
import javax.swing.JOptionPane;

/**
 *
 * @author Monique
 */
public class FrmRelatórios extends javax.swing.JFrame {

    /**
     * Creates new form FrmRelatórios
     */
    public FrmRelatórios() {
        super("Farmácia Relatórios");
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btnBuscar = new javax.swing.JButton();
        btnVoltar = new javax.swing.JButton();
        btnLimpar = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        lbla = new javax.swing.JLabel();
        txtDateS = new javax.swing.JFormattedTextField();
        lblde = new javax.swing.JLabel();
        txtDateE = new javax.swing.JFormattedTextField();
        txtSelecione = new javax.swing.JComboBox();
        lblSelecione = new javax.swing.JLabel();
        lblConsultas = new javax.swing.JLabel();
        Barra = new javax.swing.JProgressBar();
        Mensagem = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        btnBuscar.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnBuscar.setIcon(new javax.swing.ImageIcon("C:\\Users\\Monique\\Desktop\\7484_16x16.png")); // NOI18N
        btnBuscar.setText("buscar");
        btnBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarActionPerformed(evt);
            }
        });
        getContentPane().add(btnBuscar, new org.netbeans.lib.awtextra.AbsoluteConstraints(79, 340, -1, -1));

        btnVoltar.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnVoltar.setIcon(new javax.swing.ImageIcon("C:\\Users\\Monique\\Desktop\\6128_16x16.png")); // NOI18N
        btnVoltar.setText("Voltar");
        btnVoltar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnVoltarActionPerformed(evt);
            }
        });
        getContentPane().add(btnVoltar, new org.netbeans.lib.awtextra.AbsoluteConstraints(373, 340, -1, -1));

        btnLimpar.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnLimpar.setIcon(new javax.swing.ImageIcon("C:\\Users\\Monique\\Desktop\\remontkvartiry.png")); // NOI18N
        btnLimpar.setText("Limpar");
        btnLimpar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLimparActionPerformed(evt);
            }
        });
        getContentPane().add(btnLimpar, new org.netbeans.lib.awtextra.AbsoluteConstraints(224, 340, -1, -1));

        jPanel1.setBackground(new java.awt.Color(204, 255, 204));
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Informe a busca"));

        lbla.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        lbla.setText("à:");

        try {
            txtDateS.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        txtDateS.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtDateSActionPerformed(evt);
            }
        });

        lblde.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        lblde.setText("de:");

        try {
            txtDateE.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        txtDateE.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtDateEActionPerformed(evt);
            }
        });

        txtSelecione.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "- - - -", "Cadastro", "Funcionários", "Medicamentos", "Produtos de vendas" }));
        txtSelecione.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtSelecioneActionPerformed(evt);
            }
        });

        lblSelecione.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        lblSelecione.setText("Selecione:");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(31, 31, 31)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(lblSelecione)
                        .addGap(18, 18, 18)
                        .addComponent(txtSelecione, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(lblde)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(txtDateE, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(lbla)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(txtDateS, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(213, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(35, 35, 35)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblde)
                    .addComponent(txtDateE, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lbla)
                    .addComponent(txtDateS, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(26, 26, 26)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblSelecione)
                    .addComponent(txtSelecione, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(89, Short.MAX_VALUE))
        );

        getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(19, 83, 484, -1));

        lblConsultas.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
        lblConsultas.setForeground(new java.awt.Color(255, 0, 0));
        lblConsultas.setText("Consultas");
        getContentPane().add(lblConsultas, new org.netbeans.lib.awtextra.AbsoluteConstraints(161, 11, 196, 40));

        Barra.setStringPainted(true);
        Barra.addAncestorListener(new javax.swing.event.AncestorListener() {
            public void ancestorMoved(javax.swing.event.AncestorEvent evt) {
            }
            public void ancestorAdded(javax.swing.event.AncestorEvent evt) {
                BarraAncestorAdded(evt);
            }
            public void ancestorRemoved(javax.swing.event.AncestorEvent evt) {
            }
        });
        getContentPane().add(Barra, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 380, 250, -1));

        Mensagem.setForeground(new java.awt.Color(255, 0, 51));
        getContentPane().add(Mensagem, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 400, 180, 20));

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Gui/painel.jpg"))); // NOI18N
        getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 520, 440));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarActionPerformed
        new Thread(new Carregar()).start();
                          



    }//GEN-LAST:event_btnBuscarActionPerformed

    private void btnVoltarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnVoltarActionPerformed
        // TODO add your handling code here:
        this.dispose();
    }//GEN-LAST:event_btnVoltarActionPerformed

    private void txtDateEActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtDateEActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtDateEActionPerformed

    private void txtDateSActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtDateSActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtDateSActionPerformed

    private void txtSelecioneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtSelecioneActionPerformed
        // TODO add your handling code here:
        
    }//GEN-LAST:event_txtSelecioneActionPerformed

    private void btnLimparActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLimparActionPerformed
        // TODO add your handling code here:
         txtDateE.setText("");
          txtDateS.setText("");
    }//GEN-LAST:event_btnLimparActionPerformed

    private void BarraAncestorAdded(javax.swing.event.AncestorEvent evt) {//GEN-FIRST:event_BarraAncestorAdded
        // TODO add your handling code here:
    }//GEN-LAST:event_BarraAncestorAdded

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FrmRelatórios.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FrmRelatórios.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FrmRelatórios.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FrmRelatórios.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new FrmRelatórios().setVisible(true);
            }
        });
    }
    public class Carregar implements Runnable{

        @Override
        public void run() {
            for(int i=0;i<101;i++){
                
                try{
                    Thread.sleep(80);
                    Barra.setValue(i);
                    if (Barra.getValue() <= 20){
                Mensagem.setText("Efetuando busca...");
                
            }else if(Barra.getValue()<=40){
                Mensagem.setText("Carregando Banco de dados...");
            }else if(Barra.getValue()<=70){
                Mensagem.setText("Carregando sistema...");
            }else if(Barra.getValue()>99){
                Mensagem.setText("Concluido!");
                JOptionPane.showMessageDialog(null, "Busca efetuada Com Sucesso !");
                this.dispose();
                
            }
                    
            
                }catch(Exception e){
                    
                }
            }
            
            
        
    }

        private void dispose() {
            
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JProgressBar Barra;
    private javax.swing.JLabel Mensagem;
    private javax.swing.JButton btnBuscar;
    private javax.swing.JButton btnLimpar;
    private javax.swing.JButton btnVoltar;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel lblConsultas;
    private javax.swing.JLabel lblSelecione;
    private javax.swing.JLabel lbla;
    private javax.swing.JLabel lblde;
    private javax.swing.JFormattedTextField txtDateE;
    private javax.swing.JFormattedTextField txtDateS;
    private javax.swing.JComboBox txtSelecione;
    // End of variables declaration//GEN-END:variables
}
